home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 September / Chip_2000-09_cd1.bin / sharewar / Slunec / app / 16 / MOD.SWG / 0053_Audio Manager Mod (AMM) & AMS.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-08  |  23KB  |  508 lines

  1. Keys : AMM,AMS,FILE,FORMAT
  2.  
  3. Text by "mingo@n3.com.br" Eduardo Motta Buhrnheim (Mingo)
  4.       & "kenfoo@techm.pl.my" Kenneth Foo (TechnoMaestro).
  5.  
  6. AMM  (Audio  Manager  Module) & AMS  (Audio  Manager  Sample) Formats by
  7. TechnoMaestro/RDG (1995).
  8.  
  9. NOTE:   Document   partially   taken   from   Platinum   Play   III,   a
  10.       SoundBlaster-only MOD/S3M/AMM player, PP3.ZIP.
  11.  
  12. Below  are  the file formats supported  by AudioManager 3.x and Platinum
  13. Play  III. This DOC is meant for programmers only. (AMM is basically, an
  14. S3M module clone format, with several enhancements).
  15.  
  16. PROS:
  17.    - It's supports what S3M, MOD, 669, MTM ... can do. Except some
  18.      formats, like XM.
  19.    - It's usually smaller, and compresses quite well.
  20.  
  21. CONS:
  22.    - It's proprietary, and thus, there's little support.
  23.    - Not easy to implement
  24.  
  25. TERMS USED:
  26.    Track           =       Channel
  27.  
  28.  
  29. AUDIO MANAGER MODULE (AMM)
  30. Bytes │ Stuff
  31. ──────┼───────────────────────────────────────────────────────────────────
  32. 3     │ Signature 'AMM' (Audio Manager Module)
  33. ──────┼───────────────────────────────────────────────────────────────────
  34. 1     │ Character 1Ah. (End Of File marker).
  35. ──────┼───────────────────────────────────────────────────────────────────
  36. 2     │ Version of AM tracker used. LO=Minor HI=Major. 0205h = 2.05.
  37.       │ Since there ain't any AM tracker yet (maybe will never be one),
  38.       │ set this version to 0.
  39. ──────┼───────────────────────────────────────────────────────────────────
  40. 2     │ Info
  41.       │         Bit 0   1=Set MOD note range limit. (Octave 1-6) (MOD)
  42.       │                 (S3M uses limit 2-5! But what the hell!)
  43.       │             1   Reserved
  44.       │             2   1=S3M effect bugs emulation
  45.       │             3   1=Force mono playback
  46.       │             4   1=Stereo music
  47.       │          4-13   Reserved. Set to 0.
  48.       │            14  0=Standard packed patterns 1=Extra packed
  49.       │                (Bit 15 must be set for this bit to take effect)
  50.       │            15  0=Unpacked patterns (standard) 1=Packed
  51. ──────┼───────────────────────────────────────────────────────────────────
  52. 40    │ Song name.
  53. ──────┼───────────────────────────────────────────────────────────────────
  54. 2     │ Number of Tracks (Suggested max = 32) (Also PP3 max)
  55. ──────┼───────────────────────────────────────────────────────────────────
  56. 2     │ Number of patterns (Suggested max = 128. True max = 255)
  57. ──────┼───────────────────────────────────────────────────────────────────
  58. 2     │ Number of samples (Suggested max = 128. True max = 255)
  59. ──────┼───────────────────────────────────────────────────────────────────
  60. 2     │ Song length (number of orders) (Suggested max = 255)
  61. ──────┼───────────────────────────────────────────────────────────────────
  62. 2     │ Master volume (Affects the note volume.) (S3M's Global vol)
  63.       │ The resultant volume = (NoteVolume*MasterVolume)/64
  64. ──────┼───────────────────────────────────────────────────────────────────
  65. 2     │ Amplification/Mixing mode. Controls amount of multiplication on
  66.       │ resultant mixed sound wave. (S3M's Master volume)
  67.       │ 0-32767 = Amplification. Observe the below chunk of code for signed
  68.       │           samples multiplication. Note: This multiplication is not
  69.       │           done on individual samples, but on the final resultant
  70.       │           waveform to ensure quality and speed!
  71.       │
  72.       │         MOV  AX,TheSignedSoundWaveWord
  73.       │         IMUL AmplificationValue
  74.       │         SAR  AX,8
  75.       │         (CLIP WAVEFORM HERE)
  76.       │
  77.       │           This is not the actual code in AudioManager/PP3. It's
  78.       │           actually some sort more complicated.
  79.       │           I realize that there are better methods other than
  80.       │           this...but I dare not touch my code again!! Hahaha.
  81.       │           For 16-bit waveform output, the amplification is multiplied
  82.       │           by 256. (That means you can throw off the SAR AX,8 there).
  83.       │
  84.       │ 32768   = Quality SHIFT mode. Real quality shift value = Value-32768.
  85.       │ -32775    0 being the loudest. This is a method faster than using
  86.       │           master volume, but slower than the standard mixing mode.
  87.       │           The final waveform is SHIFTED x-32768 number of bits to
  88.       │           the right. (Div by exponents of 2).
  89.       │
  90.       │ 65535   = Standard mixing mode. Lowest quality, but ensures all sound
  91.       │           are played correctly without clippings.
  92. ──────┼───────────────────────────────────────────────────────────────────
  93. 1     │ Startup speed (as in effect 1)
  94. ──────┼───────────────────────────────────────────────────────────────────
  95. 1     │ Startup tempo (as in effect 2)
  96. ──────┼───────────────────────────────────────────────────────────────────
  97. 1     │ Song source
  98.       │ 0=Unknown
  99.       │ 1=AM Tracker
  100.       │ 2=MOD/NST
  101.       │ 3=S3M
  102.       │ 4=MTM
  103.       │ 5=669
  104. ──────┼───────────────────────────────────────────────────────────────────
  105.       │
  106. ──────┼───────────────────────────────────────────────────────────────────
  107. 4     │ Number of bytes in extra data section (located after samples).
  108.       │
  109. ──────┼───────────────────────────────────────────────────────────────────
  110. 13    │ Reserved
  111. ──────┼───────────────────────────────────────────────────────────────────
  112.          UP TO HERE, HEADER IS 80 BYTES LONG
  113.          AFTER THIS, ALMOST ALL DATA ARE VARIABLE SIZED
  114. ──────┼───────────────────────────────────────────────────────────────────
  115. x     │ Track pan flags. Each Track has one byte flag here.
  116.       │ These Track flags contains the position of of Track at
  117.       │ startup.
  118.       │  0 (Left most)           64 (Middle)            128 (Right)
  119.       │  255=Disabled Track      254=Surround (not supported yet)
  120.       │  129-137=Adlib channel 1-9. (NOT SUPPORTED YET & WILL CAUSE PROBLEMS)
  121. ──────┼───────────────────────────────────────────────────────────────────
  122. x     │ Pattern sequence. Each element is 2 bytes long.
  123.       │ 65534=Skipped order (padding...S3M)
  124.       │ 65535=End of song marker.
  125. ──────┼───────────────────────────────────────────────────────────────────
  126. x     │ Patterns in this format...
  127.       │ All notes throughout the song are divided into Tracks.
  128.       │ Therefore, patterns for Track 1 comes first, followed by Track 2,
  129.       │ etc... There are 64 rows per pattern. Therefore, for one pattern
  130.       │ of a one Track song, 5*64 = 320 bytes are required.
  131.       │
  132.       │ aaaabbbb cccccccc dddddddd 00yyyyyy zzzzzzzz
  133.       │ BYTE 1  (255=No note, 254=Key off (stop sample))
  134.       │         aaaa = Octave (0-7...maybe next time up to 15? :)
  135.       │         bbbb = Note (0=C, 1=C#, etc... B=B)
  136.       │ BYTE 2  (0=No sample/instrument)
  137.       │         cccccccc = Instrument number (1=1st instrument, etc...)
  138.       │ BYTE 3  dddddddd = Volume (0-64)
  139.       │ BYTE 4  xx = Unused. Keep to 0.
  140.       │         yyyyyy = Effect number
  141.       │ BYTE 5  zzzzzzzz = Effect data
  142.       │
  143.       │ Value 255 is used throughout the patterns as no-data.
  144.       │ Note 255   = No note (use previous)
  145.       │ Volume 255 = No volume
  146.       │ Sample 255 = No sample (use previous)
  147.       │ Efx 255    = No efx
  148.       │
  149.       │ However, this method wastes alot of space, and thus, I've abandoned
  150.       │ it (I still, however, use it in memory) for a new packed format.
  151.       │ As before, each tracks are separated into separate blocks...
  152.       │ For one Track, the format is as follows...
  153.       │
  154.       │ 4       Length of whole block, excluding these 4 bytes.
  155.       │ x       Event
  156.       │ x       Event
  157.       │ x       ..
  158.       │ .       ..
  159.       │
  160.       │ Each event is as follows...
  161.       │ aa [bb] [cc] [dd] [ee & ff]
  162.       │ BYTE 1  - Information byte
  163.       │           BIT 0 1=Note & instrument present (Val 255=Use previous)
  164.       │               1 1=Volume present
  165.       │               2 1=Change in effect number
  166.       │               3 1=Change in effect data
  167.       │               7 1=Data present  0=Empty rows RLE encoded .
  168.       │                   If bit set, then Bit 0-6 = Number of empty rows-1.
  169.       │                   We do not have a signal for end of pattern because
  170.       │                   it isn't necessary, as each pattern must be 64-rows
  171.       │                   and if we reach more than 64 rows, it's time to
  172.       │                   increment the pattern count.
  173.       │                   This bit can save up to 128 empty rows with just
  174.       │                   one byte! :-) Now that's COOL! :-)
  175.       │
  176.       │                   In Extended Compression mode (Bit 14 of info word)
  177.       │                   is set, this bit 7 may remain to be 0, but the next
  178.       │                   3 bits after the events (bit 4-6) = number of empty
  179.       │                   rows follows this event, 0-7.
  180.       │ aa = Info byte
  181.       │ bb = Optional note number
  182.       │ cc = Optional instrument number
  183.       │ dd = Optional volume number
  184.       │ ee = Optional effect number
  185.       │ ff = Optional effect data
  186.       │
  187.       │ All of them can be present at one time, and after this info byte,
  188.       │ it is followed by...
  189.       │ 1-BYTE Note & Instrument number (if present)
  190.       │ 1-BYTE Volume number (if present)
  191.       │ 1-BYTE New effect number (if present)
  192.       │ 1-BYTE New effect data (if present)
  193.       │
  194.       │ I used change in effect number as opposed to present effect because
  195.       │ I notice many songs, particularly S3Ms by Purple Motion/Skaven
  196.       │ uses a same effect for more than 1 row. (Esp. Vibrato,etc...)
  197.       │ Thus, I took advantage of this to create smaller files.
  198.       │ For each track, by startup, the previous effect and effect data are
  199.       │ assumed to be 255 (no efx).
  200.       │
  201.       │ The RLE, however, *DOES NOT FALL INTO THIS CONTEXT*. It is purely
  202.       │ meant for really empty tracks, with all it's values 255 in memory.
  203. ──────┼───────────────────────────────────────────────────────────────────
  204. x     │ Sample structure x NumberSamples (info for each sample)
  205.       │ Each info is 80 bytes long and is identical to the AMS format.
  206. ──────┼───────────────────────────────────────────────────────────────────
  207. x     │ Sample data
  208. ──────┼───────────────────────────────────────────────────────────────────
  209. x     │ Special data (Author name, etc...)
  210. ──────┼───────────────────────────────────────────────────────────────────
  211. x     │ Any other data that would not be loaded. :)
  212. ──────┼───────────────────────────────────────────────────────────────────
  213.  
  214.  
  215. AUDIO MANAGER SAMPLE (AMS)
  216. Bytes │ Stuff
  217. ──────┼───────────────────────────────────────────────────────────────────
  218. 3     │ Signature 'AMS' (Audio Manager Digital Sample)
  219. ──────┼───────────────────────────────────────────────────────────────────
  220. 1     │ Character 1Ah. (End Of File marker).
  221. ──────┼───────────────────────────────────────────────────────────────────
  222. 4     │ Reserved for internal use. Used to store memory handle.
  223. ──────┼───────────────────────────────────────────────────────────────────
  224. 4     │ Position within the memory block
  225. ──────┼───────────────────────────────────────────────────────────────────
  226. 4     │ Reserved. TO BE USED IN SAMPLE LIBRARY AS POINTERS TO POS IN FILE.
  227. ──────┼───────────────────────────────────────────────────────────────────
  228. 4     │ Length (NOTE! AMM can use samples much larger than 64k)
  229. ──────┼───────────────────────────────────────────────────────────────────
  230. 4     │ Loop begin offset
  231. ──────┼───────────────────────────────────────────────────────────────────
  232. 4     │ Loop past offset (the offset right after the last byte in sample)
  233. ──────┼───────────────────────────────────────────────────────────────────
  234. 4     │ C2 Sample rate (8363 is the standard value) (Not C2 actually)
  235. ──────┼───────────────────────────────────────────────────────────────────
  236. 2     │ Default playback rate (for SFX in games) ??????????????/
  237. ──────┼───────────────────────────────────────────────────────────────────
  238. 1     │ Volume (0-64)
  239. ──────┼───────────────────────────────────────────────────────────────────
  240. 2     │ Info
  241.       │         Bit 0-1 Type. 00=Adlib 01=4 bit 10=8 bit 11=16 bit
  242.       │                 4 bit samples are not linear, but logarithmic
  243.       │                 values based on internal tables.
  244.       │               2 0=Mono 1=Stereo (left right left right)
  245.       │               3 1=Looped (Loop past offset must not be 0)
  246.       │               4 0=Unsigned 1=Signed
  247.       │               5 0=Normal RAW samples 1=Delta-encoded samples
  248.       │            6-14 Reserved
  249.       │              15 0=Not loaded 1=Loaded
  250.       │
  251.       │
  252.       │                 Delta-Encoded samples use difference between two
  253.       │                 sample bytes/words to encode sample. This method,
  254.       │                 while produces the same file size, compresses
  255.       │                 better using a general purpose compressor, as
  256.       │                 their value ranges are usually small, which helps
  257.       │                 considerably the Huffman Coding compression algo.
  258.       │
  259.       │                 RAW TO DELTA-ENCODED:
  260.       │                 The starting 'previous value' for each sample is 0.
  261.       │                 Then, as each sample element is taken, it is subtracted
  262.       │                 by 'PreviousValue'. The new 'previous value' is taken
  263.       │                 as the current sample value (not the delta-encoded val)
  264.       │
  265.       │                 DELTA-ENCODED TO RAW:
  266.       │                 The starting 'previous value' for each sample is 0.
  267.       │                 Then, a delta-encoded sample is taken and added with
  268.       │                 'previous value'. The new 'previous value' is taken
  269.       │                 as the current decoded value.
  270. ──────┼───────────────────────────────────────────────────────────────────
  271. 30    │ Sample name
  272. ──────┼───────────────────────────────────────────────────────────────────
  273. 13    │ Sample file name
  274. ──────┼───────────────────────────────────────────────────────────────────
  275.  
  276. 80      TOTAL BYTES
  277.  
  278.  
  279. E F F E C T S
  280. -------------
  281.  
  282. 00xx    No effect
  283.  
  284. 01xx    Set speed
  285.         00      Use previous value
  286.         Others  Set speed. Default is 6.
  287.  
  288. 02xx    Set tempo (BPM)
  289.         00      Use previous value
  290.         Others  Set tempo (BPM) to xx. Default is 125.
  291.  
  292. 03xx    Set master volume (global volume in S3M)
  293.         Set master volume. Varies from 0 to 64.
  294.         Internally, it is multiplied by 4 for range of 0-256 used in AM3.
  295.  
  296. 04xx    Jump to order xx (hexadecimal)
  297.         Jump to next order, at row 0 (if Pattern break was not set) or
  298.         the row specified by pattern break if pattern break was set on
  299.         the same line as this command.
  300.  
  301. 05xx    Pattern break to row xx (hexdecimal! Not decimal as in other formats)
  302.         Jump to next order (if jump to order command was not used to set
  303.         the next target order), row xx.
  304.  
  305. 06xy    Volume slide.
  306.         00      Continue previous (fine/slide)
  307.         x0      Volume slide up by x
  308.         0y      Volume slide down by y
  309.         xF      Fine volume slide up by x
  310.         Fy      Fine volume slide down by y
  311.         FF      Fine volume slide up by F (slide up has more priority).
  312.  
  313. 07xy    Slide up
  314.         00      Continue previous (extra/fine/slide)
  315.         Ey      Extra fine slide up with speed y.
  316.         Fy      Fine slide up with speed y.
  317.         Others  Slide up with speed xy (if xy not [extra] fine).
  318.  
  319. 08xy    Slide down
  320.         00      Continue previous (extra/fine/slide)
  321.         Ey      Extra fine slide down with speed y.
  322.         Fy      Fine slide down with speed y.
  323.         Others  Slide down with speed xy (if xy not [extra] fine).
  324.  
  325. 09xx    Slide to note
  326.         00      Continue slide with previous *slide to note* speed.
  327.         xx      Slide to note by with speed xx.
  328.  
  329. 0Axy    Vibrato
  330.         00      Continue previous.
  331.         xy      Vibrate pitch using active waveform with speed x and
  332.                 depth y.
  333.         0y      Retains speed. Sets depth to y.
  334.  
  335. 0Bxy    Tremolo
  336.         00      Continue previous.
  337.         Others  Vibrate volume using active waveform with speed x and
  338.                 depth y.
  339.  
  340. 0Cxy    Arpeggio
  341.         00      Continue previous.
  342.         Others  Switch between 3 notes, including the current note quickly
  343.                 at every tick. Plays in the order... Current Note,
  344.                 Current Note+x semitones, Current Note+y semitones.
  345.  
  346. 0Dxy    Continue vibrato and do volume slide
  347.         00      Continue previous volume slide speed.
  348.         Others  Volume slide, with the same parameters as the normal volume
  349.                 slide.
  350.  
  351. 0Exy    Continue slide to note and do volume slide
  352.         00      Continue previous volume slide speed.
  353.         Others  Volume slide, with the same parameters as the normal volume
  354.                 slide.
  355.  
  356. 0Fxx    Set sample offset
  357.         Sets sample offset to xx*256.
  358.  
  359. 10xy    Retrigger note [+ optional volume slide]
  360.         Retriggers note and optionally do volume slide too.
  361.         x=Volume slide type
  362.                 0: 0   (No volumeslide)
  363.                 1: -1
  364.                 2: -2
  365.                 3: -4
  366.                 4: -8
  367.                 5: -16
  368.                 6: 2/3 times the original volume
  369.                 7: 1/2 times the original volume
  370.                 8: ?
  371.                 9: +1
  372.                 A: +2
  373.                 B: +4
  374.                 C: +8
  375.                 D: +16
  376.                 E: 3/2 times the original volume
  377.                 F: 2   times the original volume
  378.                 Where the original volume is the CURRENT volume.
  379.         y=Retrigger note at every y ticks.
  380.  
  381. 11xx    Set panning
  382.         00-128  Left(0)   Middle(64)    Right(128)
  383.         254     Surround (Not supported yet)
  384.         255     Disable channel
  385.  
  386. 12xx    Cut note
  387.         00      No cut
  388.         Others  Cut notes after xx ticks.
  389.  
  390. 13xx    Delay note
  391.         00      Note not played.
  392.         Others  Delays note and triggers it only after xx ticks.
  393.  
  394. 14xy    Tremor
  395.         Turns sound on for x+1 ticks and off for y+1 ticks throughout
  396.         the row.
  397.  
  398. 15xx    Pattern loop
  399.         00      Set start of loop
  400.         Others  Set end of loop and number of repetitions.
  401.  
  402. 16xx    Pattern delay
  403.         00      No delay
  404.         Others  Repeats current row x times without triggering the notes again,
  405.                 but applyin the effects.
  406.  
  407. 17xx    Set vibrato waveform to
  408.                                              xx VALUES
  409.         Waveform   Name                Retriggered  No Retrigger
  410.         ---------- ------------------- -----------  ------------
  411.         /\  /\     Sine (default)           0            4
  412.           \/  \/
  413.  
  414.         |\ |\      Ramp down                1            5
  415.           \| \|
  416.  
  417.         ,-, ,-,    Square                   2            6
  418.           '-' '-'
  419.  
  420.         ?????????  Random                   3            7
  421.  
  422.         Retrigger means that it will reset the position within the sine
  423.         table everytime a new note is encountered. By default, the
  424.         waveform is 0.
  425.  
  426. 18xx    Set tremolo waveform to xx.
  427.         See 17xx, Set vibrato waveform.
  428.  
  429. 19xx    Set glissando (Slide to note will slide in halfnotes).
  430.         00      Disable glissando
  431.         Others  Enable glissando. Usually, people use value 1 for enabling
  432.                 glissando.
  433.  
  434. 1Axx    Set sample fine tune (set C-2's frequency)
  435.         Set sample fine tune, where xx corresponds to the appropriate
  436.         frequency of C-2.
  437.         Values for X:
  438.                0       - 7895 Hz
  439.                1       - 7941 Hz
  440.                2       - 7985 Hz
  441.                3       - 8046 Hz
  442.                4       - 8107 Hz
  443.                5       - 8169 Hz
  444.                6       - 8232 Hz
  445.                7       - 8280 Hz
  446.                8       - 8363 Hz (No finetune)
  447.                9       - 8413 Hz
  448.                A       - 8463 Hz
  449.                B       - 8529 Hz
  450.                C       - 8581 Hz
  451.                D       - 8651 Hz
  452.                E       - 8723 Hz
  453.                F       - 8757 Hz
  454.         To convert amiga fine tunes to current fine tune value,
  455.         perform [(ADD 8) AND 1111b].
  456.  
  457. 1Bxx    Set filter
  458.         Amiga hardware stuff (plays with Amiga LED or something).
  459.         Not implemented.
  460.  
  461. 1Cxx    Set stereo control.
  462.         An old Scream Tracker command. Not implemented.
  463.  
  464. 1Dxx    Invert loop (aka InvertFunk/FunkRepeat?)
  465.         Plays sample backwards with speed xx. Not implemented.
  466.  
  467. 1Exx    Set event.
  468.         Sets the event flag in AM3 and sets the value of AM.MI_Event to xx.
  469.         Similar command in Scream Tracker is Zxx.
  470.  
  471. 1Fxx    Fine vibrato (S3M)
  472.         Similar to Vibrato, but 4x finer.
  473.  
  474.  
  475. SUMMARY:
  476.         MI@EFXnoEffect                  = 000h
  477.         MI@EFXsetSpeed                  = 001h
  478.         MI@EFXsetTempo                  = 002h
  479.         MI@EFXsetMasterVolume           = 003h
  480.         MI@EFXpatternJump               = 004h
  481.         MI@EFXpatternBreak              = 005h
  482.         MI@EFXvolumeSlide               = 006h
  483.         MI@EFXslideUp                   = 007h
  484.         MI@EFXslideDown                 = 008h
  485.         MI@EFXslideToNote               = 009h
  486.         MI@EFXvibrato                   = 00Ah
  487.         MI@EFXtremolo                   = 00Bh
  488.         MI@EFXarpeggio                  = 00Ch
  489.         MI@EFXvibrato_VolumeSlide       = 00Dh
  490.         MI@EFXslidetoNote_VolumeSlide   = 00Eh
  491.         MI@EFXsetSampleOffset           = 00Fh
  492.         MI@EFXretrigger                 = 010h
  493.         MI@EFXsetPan                    = 011h
  494.         MI@EFXcutNote                   = 012h
  495.         MI@EFXdelayNote                 = 013h
  496.         MI@EFXtremor                    = 014h
  497.         MI@EFXpatternLoop               = 015h
  498.         MI@EFXpatternDelay              = 016h
  499.         MI@EFXsetVibratoWaveform        = 017h
  500.         MI@EFXsetTremoloWaveform        = 018h
  501.         MI@EFXsetGlissando              = 019h
  502.         MI@EFXsetFineTune               = 01Ah
  503.         MI@EFXsetFilter                 = 01Bh
  504.         MI@EFXstereoControl             = 01Ch
  505.         MI@EFXinvertLoop                = 01Dh
  506.         MI@EFXevent                     = 01Eh
  507.  
  508.